package Route;


public class ContainerStatii extends Container {
	final static int NO_INDEX = -1;

	public ContainerStatii(Statie... statii) {
		for (Statie s : statii) {
			this.continut.add(s);
		}
	}

	private int cauta(int c) {
		int index = NO_INDEX;
		for (int i = 0; i < continut.size(); i++) {
			Statie s = (Statie)continut.get(i);
			if (s.getCod() == c) {
				index = i;
				break;
			}
		}
		return index;
	}
	
	public void sterge(int c) {
		int index = cauta(c);
		if (index != NO_INDEX) {
			this.continut.remove(index);
		}
	}
	
	public Statie getStatie(int c) {
		Statie s = null;
		int index = cauta(c);
		if (index != NO_INDEX) {
			s = (Statie) this.continut.get(index);
		}
		return s;
	}
	
	public Statie[] toVector() {
		int l = this.continut.size();
		Statie[] c = new Statie[l];
		for (int i = 0; i < l; i++) {
			c[i] = (Statie) this.continut.get(i);
		}
		return c;
	}
	
}
